package cn.iocoder.yudao.module.common.dal.mysql.favorites;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.common.dal.dataobject.favorites.FavoritesDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.common.controller.admin.favorites.vo.*;

/**
 * 收藏 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface FavoritesMapper extends BaseMapperX<FavoritesDO> {

    default PageResult<FavoritesDO> selectPage(FavoritesPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<FavoritesDO>()
                .eqIfPresent(FavoritesDO::getUserId, reqVO.getUserId())
                .eqIfPresent(FavoritesDO::getTargetId, reqVO.getTargetId())
                .eqIfPresent(FavoritesDO::getTargetType, reqVO.getTargetType())
                .betweenIfPresent(FavoritesDO::getFavoriteTime, reqVO.getFavoriteTime())
                .likeIfPresent(FavoritesDO::getCreatorName, reqVO.getCreatorName())
                .betweenIfPresent(FavoritesDO::getCreateTime, reqVO.getCreateTime())
                .likeIfPresent(FavoritesDO::getUpdaterName, reqVO.getUpdaterName())
                .eqIfPresent(FavoritesDO::getVersion, reqVO.getVersion())
                .orderByDesc(FavoritesDO::getId));
    }

}